package no.hig.imt4721.tests;

import java.text.DecimalFormat;
import java.util.List;

import no.hig.imt4721.matching.DistanceMetric;
import no.hig.imt4721.matching.Matcher;
import no.hig.imt4721.model.DataPoint;
import no.hig.imt4721.model.Subject;
import no.hig.imt4721.model.Template;
import no.hig.imt4721.presentation.Presentation;
import no.hig.imt4721.template.TemplateCreator;

public abstract class Test
{
	private String name = "";
	private List<Subject> subjects;
	private Presentation presentation;
	
	public Test(String name, List<Subject> subjects, TemplateCreator templateCreator, DistanceMetric distanceMetric)
	{
		this.name = name;
		this.subjects = subjects;
		
		templateCreator.calculate(subjects);
		
		List<Template> templates = templateCreator.getTemplates();
		List<Subject> inputs = templateCreator.getInputs();
		
		Matcher matcher = new Matcher(distanceMetric, inputs, templates);
		presentation = new Presentation(matcher);
	}

	public String getName()
	{
		return name;
	}

	public List<Subject> getSubjects()
	{
		return subjects;
	}
	
	public double getEER()
	{
		return presentation.getEER();
	}
	
	public void printEER()
	{
		DecimalFormat formatter = new DecimalFormat("00.00");
		System.out.println("EER of " + this.getName() + ": " + formatter.format(this.getEER()*100) + "%");
	}
	
	public List<DataPoint> getDataPoints()
	{
		return presentation.getDataPoints();
	}
}
